package cn.tedu.imop.gateway.config;

import com.alibaba.cloud.sentinel.SentinelProperties;
import com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类，用于注册 Sentinel 和 Nacos 数据源处理器。
 */
@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter(SentinelAutoConfiguration.class)
public class SentinelNacosDataSourceConfiguration {
    /**
     * 创建并注册 SentinelNacosDataSourceHandler bean。
     * @param sentinelProperties Sentinel 配置属性
     * @return SentinelNacosDataSourceHandler 实例
     */
    @Bean
    @ConditionalOnMissingBean
    public SentinelNacosDataSourceHandler sentinelNacosDataSourceHandler(SentinelProperties sentinelProperties) {
        System.out.println("sentinelProperties="+sentinelProperties);
        return new SentinelNacosDataSourceHandler(sentinelProperties);
    }
}